﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MvcApplication6.BIZ;
using MvcApplication6.Models;

namespace MvcApplication6.Controllers
{
    public class SalePersonController : Controller
    {
        //
        // GET: /SalePerson/

        SalePersonBIZ BIZ_Sale = new SalePersonBIZ();

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult SalePerson(SalePersonModel model)
        {
            if (Request["cmdInsert"] != null)
            {
                int check = BIZ_Sale.SalePersonInsert(model.phone, model.skype, model.yahoo);
                return RedirectToAction("SalePerson");
            }
            else if (Request["cmdUpdate"] != null)
            {
                int check = BIZ_Sale.SalePersonUpdate(model.Id, model.phone, model.skype, model.yahoo);
                return RedirectToAction("SalePerson");
            }
            else if (Request["cmdDelete"] != null)
            {
                int check = BIZ_Sale.SalePersonDelete(model.Id);
                return RedirectToAction("SalePerson");
            }
            else if (Request["cmdEdit"] != null)
            {
                model = BIZ_Sale.SalePersonSearchById(model.Id);
            }

            ViewBag.salePerson = BIZ_Sale.SalePersonSearch();

            return View(model);
        }
    }
}
